blob: 2665a149dd399297567bbe595d23970a8de2a32f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "functionrandom.h"
#include "gamestate.h"
#include <stdlib.h>
FunctionRandom::FunctionRandom()
{
}
FunctionRandom::~FunctionRandom()
{
}
void FunctionRandom::call( class GameState &gState )
{
Variable vHigh = gState.popDeref();
Variable vLow = gState.popDeref();
if( vHigh.getType() != vLow.getType() )
throw Bu::ExceptionBase("Different types in random!");
if( vLow.getType() == Variable::tInt )
{
gState.push( Variable( (int64_t)(
(random()%(vHigh.getInt()-vLow.getInt()+1ll))+vLow.getInt()
) ) );
}
}
|